package cn.itcast.demo.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;


@Configuration
//@EnableConfigurationProperties(JdbcProperties.class)//把资源类读取
public class JdbcSpringbootConfig {

//    @Autowired
//    private JdbcProperties jdbcProp;

    @Bean //xml 中的<bean标签> 交给spring的 IOC容器
    @ConfigurationProperties(prefix = "jdbc")
    public DataSource dataSource(){//setDriverClassName
        DruidDataSource dataSource = new DruidDataSource();
        return dataSource;
    }
}
